<?php
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/dist/js/jquery.bootstrap-duallistbox.js");
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . "/css/dist/css/bootstrap-duallistbox.css");

$this->breadcrumbs = array(
    '主题管理' => array('/manage/topic/manage'),
    $model->isNewRecord?'主题新建':'主题更新',
);
$action = $model->isNewRecord ? 'create' : 'update?id='.$model->id;
?>
<div class="row" style="min-height:300px;background-color:#fff;">
    <?php

    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
        'id' => 'CreateForm',
        'action' => $action,
        'type' => 'horizontal',
        'enableAjaxValidation' => false,
        'enableClientValidation' => true,
        'clientOptions' => array(
            'validateOnSubmit' => true,
        ),
        'htmlOptions'=>array('enctype'=>'multipart/form-data'),
    ));
    if ($form instanceof TbActiveForm) {

    }
    ?>
    <blockquote><b><?php echo  $model->isNewRecord?'新建':'更新'?></b></blockquote>
    <div class="col-md-12">
        <?php
        echo $form->textFieldRow($model, 'name');
        echo $form->textFieldRow($model, 'color');
        if(!empty($model->url))
        {
            echo CHtml::tag('div',['class'=>'form-group'],"<label class='control-label col-sm-3'>预览图：</label>".'<div class="control-input col-sm-6">'.CHtml::image($model->url).'</div>');
        }
        echo $form->fileFieldRow($model, 'pic');
        ?>
    </div>
    <div class="col-md-12">
        <div class="control-label col-md-3">
            选择关联分类
        </div>
        <div class="col-md-6">
            <?php
            echo CHtml::activeDropDownList($model, 'sids', Series::getOptions('series'),
                ['id'=>'linksids','multiple' => true, 'data-select' => 'dual']);
            ?>
        </div>

    </div>

    <div class="col-md-12">
        <?php

        $this->widget('bootstrap.widgets.TbButton', array(
            'buttonType' => 'submit',
            'type' => 'primary',
            'label' => '保存',
            'htmlOptions' => array('class' => 'submit', 'style' => 'width:120px;margin:15px 400px;'),
        ));
        ?>
    </div>
    <?php
    $this->endWidget();
    ?>
</div>
<script>
    $(function () {
        $('#Topic_color').colorpicker();
    });
    $("#linksids").bootstrapDualListbox({
        nonSelectedListLabel: '可选择分类',
        selectedListLabel: '已经选择分类',
        preserveSelectionOnMove: 'moved',
        sortByInputOrder:true
    });
</script>

